﻿using System;
using System.Collections.Generic;
using System.Text;
using System.Text.RegularExpressions;

using IOFileServer.ZMPhoneticEnglish.Models;

namespace IOFileServer.ZMPhoneticEnglish.Implementation
{
    /// <summary>
    /// 实现类: 英文单词拼读计算处理工具
    /// </summary>
    public class WordPronunciationCalcHandle : IWordPronunciationCalcHandle, IVowel
    {
        /// <summary>
        /// 实例化实现类: 英文单词拼读计算处理工具
        /// </summary>
        public WordPronunciationCalcHandle()
        {
        }

        WordPronunciationCalcResult IWordPronunciationCalcHandle.Calc(string word)
        {
            if (string.IsNullOrEmpty(word) || string.IsNullOrWhiteSpace(word))
                return null;
            word = Regex.Replace(word, @"[^a-zA-Z]", "");
            word = word.ToLower().Trim();
            WordPronunciationCalcResult r = new WordPronunciationCalcResult()
            {
                Word = word,
            };
            return r;
        }

        int[][] IVowel.CalcPosition(string word)
        {

            WordPronunciationRule[] rules = new WordPronunciationRule[]
            {
                new WordPronunciationRule() {
                    Sign = "vowel.large.u",
                    Pronunciation = "",
                },
            };

            SetVowelRule("a", "哎(大口)", "");
            SetVowelRule("e", "哎(微笑的小口)", "");
            SetVowelRule("i", "一/英文`A`", "");
            SetVowelRule("o", "奥(圆口)", "");
            SetVowelRule("u", "啊(口向上)", "");
            SetVowelRule("ar", "啊&耳(和在一起读一个音)", "");
            SetVowelRule("or", "奥&耳(和在一起读一个音)", "");
            SetVowelRule("ur", "耳", "");
            SetVowelRule("ea", "哎.小口(e)", "");
            SetVowelRule("ea", "E(e-e)", "");
            SetVowelRule("(w)a", "奥(o)", "");
            SetVowelRule("ou", "啊(u)", "");
            SetVowelRule("ai", "A(a-e)", "");
            SetVowelRule("ay", "A(a-e)", "");
            SetVowelRule("ey", "A(a-e)", "");
            SetVowelRule("eigh", "A(a-e)", "");
            SetVowelRule("ee", "E(e-e)", "");
            SetVowelRule("ei", "E(e-e)", "");
            SetVowelRule("ie-", "E(e-e)", "");
            SetVowelRule("-ie-", "E(e-e)", "");
            SetVowelRule("-ie", "I(i-e)", "");
            SetVowelRule("igh", "I(i-e)", "");
            SetVowelRule("i(nd)", "I(i-e)", "");
            SetVowelRule("i(ld)", "I(i-e)", "");
            SetVowelRule("oe", "O(o-e)", "");
            SetVowelRule("oa", "O(o-e)", "");
            SetVowelRule("ue", "U(u-e)", "");
            SetVowelRule("ui", "U(u-e)", "");
            SetVowelRule("ew", "U(u-e)", "");
            SetVowelRule("eu", "U(u-e)", "");
            SetVowelRule("aw", "奥(or)", "");
            SetVowelRule("au", "奥(or)", "");
            SetVowelRule("al", "奥(or)", "");
            SetVowelRule("ir", "耳(ur)", "");
            SetVowelRule("er", "耳(ur)", "");
            SetVowelRule("(w)or", "奥(or)", "");
            SetVowelRule("air", "爱耳", "");
            SetVowelRule("are", "爱耳(air)", "");
            SetVowelRule("eir", "爱耳(air)", "");
            SetVowelRule("ear", "叶耳", "");
            SetVowelRule("ear", "爱耳(air)", "");
            SetVowelRule("ere", "叶耳(ear)", "");
            SetVowelRule("eer", "叶耳(ear)", "");
            SetVowelRule("oi", "奥A", "");
            SetVowelRule("oo", "物", "");
            SetVowelRule("ow", "啊奥", "");
            SetVowelRule("-ow", "O(o-e)组合补充", "");
            SetVowelRule("-ow-", "O(o-e)组合补充", "");
            SetVowelRule("own", "昂组合补充", "");
            SetVowelRule("ou", "啊奥(oo)", "");

            return null;
        }

        private void SetVowelRule(string expression, string pronunciation, string describe)
        {
        }
    }
}
